import 'package:backend.core/core/domain/entities/api/google_play/api_google_play_purchased_subscription_cancellation_info.dart';
import 'package:backend.purchases/infrastructure/dtos/api/google_play/api_google_play_purchased_subscription_cancellation_info_dto.dart';
import 'package:backend.purchases/infrastructure/dtos/api/google_play/api_google_play_purchased_subscription_developer_cancellation_info_dto.dart';
import 'package:backend.purchases/infrastructure/dtos/api/google_play/api_google_play_purchased_subscription_new_subscription_cancellation_info_dto.dart';
import 'package:backend.purchases/infrastructure/dtos/api/google_play/api_google_play_purchased_subscription_system_cancellation_info_dto.dart';
import 'package:backend.purchases/infrastructure/dtos/api/google_play/api_google_play_purchased_subscription_user_cancellation_info_dto.dart';

class ApiGooglePlayPurchasedSubscriptionCancellationInfoDtoFactory {
  const ApiGooglePlayPurchasedSubscriptionCancellationInfoDtoFactory._internal();

  static const _instance = ApiGooglePlayPurchasedSubscriptionCancellationInfoDtoFactory._internal();

  factory ApiGooglePlayPurchasedSubscriptionCancellationInfoDtoFactory() {
    return _instance;
  }

  ApiGooglePlayPurchasedSubscriptionCancellationInfoDto fromEntity(
      ApiGooglePlayPurchasedSubscriptionCancellationInfo cancellationInfo) {
    if (cancellationInfo is ApiGooglePlayPurchasedSubscriptionUserCancellationInfo) {
      return ApiGooglePlayPurchasedSubscriptionUserCancellationInfoDto.fromEntity(cancellationInfo);
    }

    if (cancellationInfo is ApiGooglePlayPurchasedSubscriptionSystemCancellationInfo) {
      return const ApiGooglePlayPurchasedSubscriptionSystemCancellationInfoDto();
    }

    if (cancellationInfo is ApiGooglePlayPurchasedSubscriptionDeveloperCancellationInfo) {
      return const ApiGooglePlayPurchasedSubscriptionDeveloperCancellationInfoDto();
    }

    if (cancellationInfo is ApiGooglePlayPurchasedSubscriptionNewSubscriptionCancellationInfo) {
      return const ApiGooglePlayPurchasedSubscriptionNewSubscriptionCancellationInfoDto();
    }

    throw UnimplementedError();
  }
}
